package com.bifang.module.file.gateway.controller;

import com.bifang.module.file.core.biz.FileCollectDataIntegration;
import com.bifang.module.file.common.vo.fileCollectData.FileCollectDataVO;
import com.bifang.module.file.common.vo.fileCollectData.FileCollectDataKeyVO;
import com.bifang.module.file.common.vo.fileCollectData.FileCollectDataQueryVO;
import com.github.pagehelper.PageInfo;
import com.bifang.engine.assistant.core.domain.AppResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import com.bifang.engine.protect.core.annotation.Idempotent;
import org.springframework.validation.annotation.Validated;
import com.bifang.assistant.common.constants.Validators;

/**
 * 文件信息表网关
 *
 * @author xyh
 * @since 2023-03-22
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "文件信息表", description = "文件信息表")
public class FileCollectDataController {

    @Autowired
    public FileCollectDataIntegration fileCollectDataIntegration;

    @Operation(summary = "文件信息表分页查询",description = "文件信息表分页查询")
    @PostMapping(value = "/fileCollectData0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileCollectDataVO>> getList(@RequestBody @Validated FileCollectDataQueryVO vo) {
        return AppResponse.successData(fileCollectDataIntegration.getList(vo));
    }

    @Operation(summary = "文件信息表根据主键查询详情",description = "文件信息表根据主键查询详情")
    @PostMapping(value = "/fileCollectData0002", produces = "application/json;charset=UTF-8")
    public AppResponse<FileCollectDataVO> getById(@RequestBody @Validated FileCollectDataKeyVO vo) {
        return AppResponse.successData(fileCollectDataIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件信息表新增",description = "文件信息表新增")
    @PostMapping(value = "/fileCollectData0004", produces = "application/json;charset=UTF-8")
    public AppResponse<FileCollectDataVO> add(@RequestBody @Validated(value = {Validators.Add.class}) FileCollectDataVO vo) {
        return AppResponse.successData(fileCollectDataIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件信息表修改",description = "文件信息表修改")
    @PostMapping(value = "/fileCollectData0005", produces = "application/json;charset=UTF-8")
    public AppResponse<FileCollectDataVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) FileCollectDataVO vo) {
        return AppResponse.successData(fileCollectDataIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件信息表删除",description = "文件信息表删除")
    @PostMapping(value = "/fileCollectData0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated FileCollectDataKeyVO vo) {
        fileCollectDataIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件信息归集",description = "文件信息归集")
    @PostMapping(value = "/fileCollectData0007", produces = "application/json;charset=UTF-8")
    public AppResponse<FileCollectDataVO> addCollect(@RequestBody @Validated(value = {Validators.Add.class}) FileCollectDataVO vo) {
        return AppResponse.successData(fileCollectDataIntegration.addCollect(vo));
    }

}
